# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=libde265
pkgver=1.0.15
pkgrel=0
pkgdesc="Open h.265 video codec implementation"
url="https://github.com/strukturag/libde265"
arch="all"
license="LGPL-3.0-or-later"
makedepends="autoconf automake libtool"
options="!check"  # no tests provided
subpackages="$pkgname-dev $pkgname-examples"
source="https://github.com/strukturag/libde265/releases/download/v$pkgver/libde265-$pkgver.tar.gz
	disable_tools.patch
	export-only-decoder-api.patch
	"
# secfixes:
#   1.0.15-r0:
#     - CVE-2023-49465
#     - CVE-2023-49467
#     - CVE-2023-49468
#   1.0.11-r1:
#     - CVE-2023-27102
#     - CVE-2023-27103
#   1.0.11-r0:
#     - CVE-2020-21594
#     - CVE-2020-21595
#     - CVE-2020-21596
#     - CVE-2020-21597
#     - CVE-2020-21598
#     - CVE-2020-21599
#     - CVE-2020-21600
#     - CVE-2020-21601
#     - CVE-2020-21602
#     - CVE-2020-21603
#     - CVE-2020-21604
#     - CVE-2020-21605
#     - CVE-2020-21606
#     - CVE-2022-43236
#     - CVE-2022-43237
#     - CVE-2022-43238
#     - CVE-2022-43239
#     - CVE-2022-43240
#     - CVE-2022-43241
#     - CVE-2022-43242
#     - CVE-2022-43243
#     - CVE-2022-43244
#     - CVE-2022-43245
#     - CVE-2022-43248
#     - CVE-2022-43249
#     - CVE-2022-43250
#     - CVE-2022-43252
#     - CVE-2022-43253
#     - CVE-2022-47655
#   1.0.8-r2:
#     - CVE-2021-35452
#     - CVE-2021-36408
#     - CVE-2021-36410
#     - CVE-2021-36411
#     - CVE-2022-1253

prepare() {
	default_prepare
	autoreconf -fvi
}

build() {
	# This is en/decoder, so performance matters more than size.
	export CPPFLAGS="${CPPFLAGS/-Os/-O2}"
	export CXXFLAGS="${CXXFLAGS/-Os/-O2}"

	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--disable-sherlock265
	make
}

package() {
	make DESTDIR="$pkgdir" install

	# The upstream do the same in their Ubuntu/PPA packages.
	mv "$pkgdir"/usr/bin/dec265 "$pkgdir"/usr/bin/libde265-dec265
}

examples() {
	pkgdesc="$pkgdesc (examples)"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/*
}

sha512sums="
375d8e781108247e0e8b4d7a036d20cc5d0670bdbf6ddb40a6d3dbf912fa776d2f001fb762301cb97e4d43be29eb415b0cdbfc6e07aa18b3f2346f7409c64fce  libde265-1.0.15.tar.gz
1c702f229e2bafb2e72c90aed55b14691fa8f216ea855931197b8cd266c701ce2679a8f143651bdf984d7ac79a66a0d84b603822601a800ffb504461399d84ee  disable_tools.patch
f7bd3799f4e4440e7efb98671eca425a5926dd526f8b1147cee2e49b1995853f67b63287c12739ef8ea680713af903517820f83f7f88eac6459f37bae01b4d50  export-only-decoder-api.patch
"
